#include <stdio.h>
#include <stdlib.h>
typedef struct node *ptr;
struct node {
    int data;
    ptr next;
};
int main()
{
    int k, n;
    scanf("%d", &k);
    ptr head = (ptr)malloc(sizeof(struct node));
    head->next = NULL;
    ptr p = head;
    while (scanf("%d", &n) != EOF && n >= 0) {
        ptr q = (ptr)malloc(sizeof(struct node));
        q->data = n;
        q->next = NULL;
        p->next = q;
        p = q;
    }
    //calculate the length of list
    int len = 0;
    p = head->next;
    while (p) {
        len++;
        p = p->next;
    }
    if (k > len) {
        printf("NULL");
        return 0;
    }
    //find K from the bottom
    p = head->next;
    int i;
    for (i = 1; i < len - k + 1; i++) {
        p = p->next;
    }
    printf("%d", p->data);
    return 0;
}